# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=roc-toolkit
pkgver=0.2.6
pkgrel=1
pkgdesc="Real-time audio streaming over the network"
arch=(loong64 x86_64)
url="https://github.com/roc-streaming/roc-toolkit/"
license=(
  CC0-1.0
  MPL-2.0
)
depends=(
  glibc
  gcc-libs
  libunwind
  libuv
)
makedepends=(
  alsa-lib
  cpputest
  gengetopt
  libpulse
  openfec
  ragel
  scons
  sox
  speexdsp
)
optdepends=(
  'libpulse: for roc-conv, roc-receive and roc-send'
  'sox: for roc-conv, roc-receive and roc-send'
)
provides=(libroc.so)
source=($url/archive/v$pkgver/$pkgname-v$pkgver.tar.gz)
sha512sums=('ac0f18e8a8a60ae9e93f3dcb58e645f31440b6799dac063b246f5320978ac98192bb9c38bbfa7e38dbd537da169c1d525d93cf66c86b36976d37932e3c12f63b')
b2sums=('6fa38819fc675323585a0bd5f754b7325be0d9870a55b65636498822249fe1d53b23422b7fa6a0b7e7740aff4f7e62fed9b2681741fbd8912ef8ec2bcc375ee4')

build() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
    --disable-openssl  # disable as it is not yet used
    --enable-tests
    --enable-examples
  )

  cd $pkgname-$pkgver
  scons "${scons_options[@]}"
}

check() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
    --disable-openssl  # disable as it is not yet used
    --enable-tests
    --enable-examples
  )

  cd $pkgname-$pkgver
  scons test "${scons_options[@]}"
}

package() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
  )
  depends+=(
    openfec libopenfec.so
    speexdsp libspeexdsp.so
  )

  cd $pkgname-$pkgver
  scons DESTDIR="$pkgdir/" "${scons_options[@]}" install

  install -vDm 644 3rdparty/hedley/COPYING -t "$pkgdir/usr/share/licenses/$pkgname/hedley.COPYING"
}
